import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class HomeRollNews extends StatefulWidget {
  final List<dynamic> rollnews;

  HomeRollNews({this.rollnews});

  @override
  _HomeRollNewsState createState() => _HomeRollNewsState();
}

class _HomeRollNewsState extends State<HomeRollNews> {
  PageController _controller;

  @override
  void initState() {
    super.initState();
    _controller = PageController();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 720.w,
      color:Colors.white,
      margin: EdgeInsets.all(10),
      height: 100.w,
      padding:EdgeInsets.all(10),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisSize: MainAxisSize.max,
        children: [
          Text('新闻简报'),
          VerticalDivider(),
          Expanded(
            flex: 1,
            child: Container(
              alignment: Alignment.centerLeft,
              child: Swiper(
                itemHeight:100.w,
                itemWidth: 500.w,
                itemBuilder: (BuildContext context, int index) {
                  return new Text(widget.rollnews[index]['info'],textAlign: TextAlign.center,maxLines: 1,overflow: TextOverflow.ellipsis,);
                },
                scrollDirection:Axis.vertical,
                itemCount: widget.rollnews.length,
                autoplay:true,
              ),
            ),
          ),
          Icon(Icons.chevron_right)
        ],
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }
}
